home *** CD-ROM | disk | FTP | other *** search
/ Workplace Effectiveness:…ecision-Making Strategies / Workplace Effectiveness: Decision-Making Strategies.iso / pc / Files / Sound.dxr / 00002_horizontal slider behavior.ls < prev    next >
Encoding:
Text File  |  1998-12-03  |  2.3 KB  |  55 lines

  1. property rightLoc, leftLoc, numStops, vertical, snapLocs, notchLength
  2. global gMachineData
  3.  
  4. on mouseDown me
  5.   set vNewLocH to getAt(the snapLocs of me, the currSndVolume of gMachineData + 1)
  6.   repeat while the mouseDown
  7.     set vSlideLoc to the mouseH
  8.     case 1 of
  9.       (vSlideLoc < the leftLoc of me):
  10.         set the loc of sprite the spriteNum of me to point(the leftLoc of me, the vertical of me)
  11.         set vNewLocH to the leftLoc of me
  12.       (vSlideLoc > the rightLoc of me):
  13.         set the loc of sprite the spriteNum of me to point(the rightLoc of me, the vertical of me)
  14.         set vNewLocH to the rightLoc of me
  15.       otherwise:
  16.         set the loc of sprite the spriteNum of me to point(the mouseH, the vertical of me)
  17.         set vNewLocH to vSlideLoc
  18.     end case
  19.     updateStage()
  20.   end repeat
  21.   set vNewNotch to integer((vNewLocH - the leftLoc of me) / the notchLength of me) + 1
  22.   newSnap(me, vNewNotch)
  23.   setVolume(gMachineData, vNewNotch - 1)
  24. end
  25.  
  26. on newSnap me, thisNotch
  27.   set snapPointH to getAt(the snapLocs of me, thisNotch)
  28.   set the loc of sprite the spriteNum of me to point(snapPointH, the vertical of me)
  29.   updateStage()
  30. end
  31.  
  32. on beginSprite me
  33.   set the notchLength of me to 1.0 * (the rightLoc of me - the leftLoc of me) / (the numStops of me - 1)
  34.   set vStopsList to []
  35.   sort(vStopsList)
  36.   add(vStopsList, the leftLoc of me)
  37.   add(vStopsList, the rightLoc of me)
  38.   repeat with X = 1 to the numStops of me - 2
  39.     add(vStopsList, integer(X * the notchLength of me) + the leftLoc of me)
  40.   end repeat
  41.   set the snapLocs of me to vStopsList
  42.   set vLevel to the currSndVolume of gMachineData + 1
  43.   set the vertical of me to the locV of sprite the spriteNum of me
  44.   set the loc of sprite the spriteNum of me to point(getAt(the snapLocs of me, vLevel), the vertical of me)
  45. end
  46.  
  47. on getPropertyDescriptionList
  48.   set myProps to [#leftLoc: [#comment: "Left location (smaller number):", #format: #integer, #default: 0], #rightLoc: [#comment: "Right location (bigger number):", #format: #integer, #default: 640], #numStops: [#comment: "Number of snap-to positions:", #format: #integer, #default: 0]]
  49.   return myProps
  50. end
  51.  
  52. on getBehaviorDescription
  53.   return "A horizontal slider with a series of stop points. Left is lowest, right is highest. Controls/communicates with two objects (globals)."
  54. end
  55.